/**
 * 
 */
package com.mbengue.corp.apr.ra.core;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author MMB11447
 *
 */
@Entity
@Table(name = "article", schema = "apr_ra")
@NamedQueries(value = {
    @NamedQuery(name = "articlesParDate", query = "SELECT art FROM Article art WHERE art.dateDeCreation=:date"),
    @NamedQuery(name = "articles", query = "SELECT art FROM Article art WHERE art.type=:type") })
public class Article implements Serializable {
  private static final long serialVersionUID = 1L;
  @Id
  @Column(nullable = false, unique = true, length = 64)
  private String titre;
  @Column(nullable = false, unique = false, columnDefinition = "text")
  private String resume;
  @Column(nullable = false, unique = false, columnDefinition = "longtext")
  private String contenu;
  @Temporal(TemporalType.TIMESTAMP)
  @Column(nullable = false, unique = false, length = 16)
  private Date dateDeCreation;
  @Column(nullable = false, length = 11)
  private String type;

  /**
   * @return the titre
   */
  public String getTitre() {
    return titre;
  }

  /**
   * @param titre the titre to set
   */
  public void setTitre(String titre) {
    this.titre = titre;
  }

  /**
   * @return the resume
   */
  public String getResume() {
    return resume;
  }

  /**
   * @param resume the resume to set
   */
  public void setResume(String resume) {
    this.resume = resume;
  }

  /**
   * @return the contenu
   */
  public String getContenu() {
    return contenu;
  }

  /**
   * @param contenu the contenu to set
   */
  public void setContenu(String contenu) {
    this.contenu = contenu;
  }

  /**
   * @return the dateDeCreation
   */
  public Date getDateDeCreation() {
    return dateDeCreation;
  }

  /**
   * @param dateDeCreation the dateDeCreation to set
   */
  public void setDateDeCreation(Date dateDeCreation) {
    this.dateDeCreation = dateDeCreation;
  }

  public String getStrDate() {
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
    return sdf.format(dateDeCreation);
  }

  /**
   * @return the type
   */
  public String getType() {
    return type;
  }

  /**
   * @param type the type to set
   */
  public void setType(String type) {
    this.type = type;
  }

  public Article(String titre, String resume, String contenu, Date dateDeCreation, String type) {
    super();
    this.titre = titre;
    this.resume = resume;
    this.contenu = contenu;
    this.dateDeCreation = dateDeCreation;
    this.type = type;
  }

  public Article() {
  }
}
